class Person {
    name
    gender

    constructor(name, gender) {
        this.name = name
        this.gender = gender
    }

    sleep() {
        return `${this.name} 休息中...`
    }
}

// 继承 Person 类 
class Tom extends Person {
    web
    constructor(name, gender, web) {
        // 调用父类构造函数
        super(name, gender)
        this.web = web
    }
    eat() {
        return `${this.name} 正在吃东西...`
    }
}

let tom = new Tom('Tom', '男', 'https://www.tom.com')
console.log("tom:", tom)
console.log("tom.web:", tom.web)
console.log("tom.eat():", tom.eat())
console.log("tom.gender:", tom.gender)
console.log("tom.sleep():", tom.sleep())
/*
tom: Tom { name: 'Tom', gender: '男', web: 'https://www.tom.com' }
tom.web: https://www.tom.com
tom.eat(): Tom 正在吃东西...
tom.gender: 男
tom.sleep(): Tom 休息中...
*/
